﻿'Imports BasicLib
Public Class frmCreateCopyFile
    ''' <summary>
    ''' TextEditor対象
    ''' </summary>
    ''' <remarks></remarks>
    Dim mCodeEdit As TextBoxPrj.CodeEditor
    Sub New(ByVal CodeEdit As TextBoxPrj.CodeEditor)
        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        ' Add any initialization after the InitializeComponent() call.
        mCodeEdit = CodeEdit
    End Sub
    Sub New()

        ' 此调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        ' 在 InitializeComponent() 调用之后添加任何初始化。

    End Sub
    Private Sub frmCreateCopyFile_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'レベル番号リストの初期化
        cmbItemLV.Items.Add("データ名を定義する")
        cmbItemLV.Items.Add("データ名を再命名する-LV66")
        cmbItemLV.Items.Add("データ名を定義する-LV77")
        cmbItemLV.Items.Add("条件名を定義する-LV88")
        cmbItemLV.SelectedIndex = 0
    End Sub
    ''' <summary>
    ''' PIC句作成ツールを呼び出す
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub btnGenratePic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenratePic.Click
        Using mForm As New frmPICGenerate
            If mForm.ShowDialog = Windows.Forms.DialogResult.OK Then
                Me.txtDataDefine.Text = mForm.strDesciprtion
            End If
        End Using
    End Sub

    Private Sub btnInsertToDoc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsertToDoc.Click
        Dim strInsert As String = String.Empty
        Select Case cmbItemLV.SelectedIndex
            Case 0
                strInsert = Format(nudLV.Value, "0#")
            Case 1
                strInsert = Format(66, "0#")
            Case 2
                strInsert = Format(77, "0#")
            Case 3
                strInsert = Format(88, "0#")
        End Select
        If chkOCCURS.Checked Then
            strInsert &= Space(4) & "OCCURS" & Space(2) & nudOCCURS.Value & Space(2) & "TIMES"
        End If
        strInsert &= Space(4) & txtItemName.Text & Space(4) & txtDataDefine.Text
        If mCodeEdit IsNot Nothing Then
            mCodeEdit.InsertString(strInsert)
            Me.Close()
        Else
            MsgBox(strInsert)
        End If
    End Sub
    Private Sub chkOCCURS_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkOCCURS.CheckedChanged
        nudOCCURS.Enabled = chkOCCURS.Checked
    End Sub
End Class
'Sub Test()
'    Dim mRoot As New clsDataStru
'    mRoot.Level = 10
'    mRoot.Name = "MQBO"
'    mRoot.Description = "MQBO structure"
'    Dim SubA As New clsDataStru
'    SubA.Level = 15
'    SubA.Name = "MQBO-STRUCID"
'    SubA.Description = "Structure identifier"
'    SubA.DataType = "PIC"
'    SubA.DataTypeOptional = "X(4)"
'    mRoot.AddSubData(SubA)
'    'WriteObjectToXMLFile(mRoot, GetType(clsDataStru), "C:\Copy.xml")
'End Sub
